#!/bin/sh
DELAY=1
null() {
	:
}

case "$1" in
-q)	echo "echo off"
	ECHO="null"
	shift ;;
[1-9]*)
	DELAY=$1
	ECHO=echo
	shift ;;
*)
	echo "echo on"
	ECHO=echo
esac

vmstat $DELAY | while read LINE ; do
	LINE="`date +%s`: $LINE"
	$ECHO "$LINE"
	[ "$1" ] && echo "$LINE" >> $1
done
